<template>
	<view>
		
		<view v-for="(items,indexs) in fields" :key="indexs" class="form-item">
			<view class="" v-if="items.type=='radio'">
				<radio-group @change="radioClick($event,items.title,indexs)">
					<text>{{items.title}}:</text>
					<label class="radio" v-for="(item,index) in items.options" :key="index">
						 <radio style="margin-left: 40rpx;" :value="item.value"  :checked="index==radioValue?true:false" /><text>{{item.label}}</text>
					</label>
				</radio-group>
			</view>
			
		</view>
	
	</view>
</template>

<script>
	export default {
		props:{
			fields:{
				type:Array,
				default:[]
			},
			formData:{
				type:Array,
				default:[]
			}
		},
		data() {
			return {
				radioValue:0
			}
		},
		mounted() {
			
		},
		methods: {
			radioClick(e,title,index){
				let data={}
				this.$set(data,title,e.detail.value)
				this.formData[index]=data
				this.$emit('update:formData', this.formData)
				console.log(this.formData,'this.formData')
			}
		}
	}
</script>

<style scoped>
.form-item{
	background-color: white;
	margin: 20rpx;
	padding: 30rpx;
	border-radius: 20rpx;
}
</style>